<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <!--{include file='comm/header.tpl'}-->
    <title>订单修改提示</title>
    <style type="text/css">
        .flexigrid div.bDiv td{
            vertical-align: middle!important;
        }
    </style>
</head>

<body>
<div class="container">

    <div class="comm_content">

        <div class="search-box">
            <div style="position:relative">
                <form id="search_form" onsubmit="return false;" class="form-inline">

                    <span >
                    	到货日期：<input type="text" name="send_date" readonly id="send_date"  value="<!--{$currentDate}-->" class="form-control w100" />
                    </span>

                	<span>
                    	订单编号：<input type="text" name="bill_code" id="bill_code" class="form-control w150" />
                    </span>

                    <span>
                    	订单状态：
                        <select  class="form-control w150" id="bill_status" name="bill_status">
                            <option value="">请选择</option>
                            <!--mod by yim.hu 20141127 FUN-BK-0030 订单分配页面增加标识退货的订单--start -->

                            <option value="2">已打印生产单</option>
                            <option value="3">已质检入库</option>
                            <option value="4">已上车</option>
                            <!--mod by yim.hu 20141127 FUN-BK-0030 订单分配页面增加标识退货的订单--end -->
                        </select>
                    </span>

                    <span>
                        配送城市：
                        <select id="cityID" name="cityID" class="form-control input-sm" style="width:100px;">
                            <option value="">请选择</option>
                        </select>
                    </span>

                    <span>
                        配送站：
                        <select name="distribution_id" id="distribution_id" class="form-control input-sm" style="width:110px;">
                            <option value="">请选择</option>
                        </select>
                    </span>

                    <span>
                    	<input type="button" value="查询" class="btn btn-primary" onclick="productionOrder.search();" />
                    </span>
                    <span>
                        <button onclick="productionOrder.clearUp();" id="clearBtn" class="btn btn-warning" type="button">重置</button>
                    </span>
                </form>
            </div>
        </div>

        <table id="flex" style="display:none"></table>

    </div>
    <div class="comm_crub">
        <span class="now_crub" style="margin-left:12px;">今日打印生产单情况一览表</span>
    </div>
    <table id="flex_print" style="display:none"></table>


</div>


<script type="text/javascript">

//日期只能筛选今天和今天之后
$('#send_date').datepicker({
        minDate: new Date()
});

$("#flex").flexigrid({
    url:"/invokingAjax-backend/production/orderModify.ajax?operFlg=1&xjx=none",
    dataType: "json",
    colModel : [
        {display: "操作", width : 80, align: "center"},
        {display: "流水号",width : 80, align: "center", name : "notice_id", sortable : true},
        {display: "订单状态", width : 90, align: "center"},
        {display: "订单编号", width : 120, align: "center"},
        {display: "配送站", width : 90, align: "center"},
        {display: "商品", width : 400, align: "left"},
        {display: "变更信息", width : 180, align: "center"}
    ],
    //add by 20141104 allen.qiang FUN-BK-0018-订单修改提示界面改造 start
    height:200,
    //add by 20141104 allen.qiang FUN-BK-0018-订单修改提示界面改造 end
    sortname: "notice_id",
    sortorder: "desc",
    usepager: true,
    rp: 10,
    useRp: true,
    showTableToggleBtn: true,
    onSubmit: function() {
        var dt = $('#search_form').serializeArray();
        $("#flex").flexOptions({params: dt});
        return true;
    }
});
//add by 20141104 allen.qiang FUN-BK-0018-订单修改提示界面改造 start
$("#flex_print").flexigrid({
    url:"/invokingAjax-backend/production/orderModify.ajax?operFlg=5&xjx=none",
    dataType: "json",
    colModel : [
        {display: "城市", width : 80, align: "center"},
        {display: "已打印生产单数量",width : 120, align: "center"},
        {display: "未打印生产单数量", width : 120, align: "center"}
    ],
    height:80,
    usepager: false,
    useRp: false,
    showTableToggleBtn: true,
    onSubmit: function() {
        var dt = $('#search_form').serializeArray();
        $("#flex_print").flexOptions({params: dt});
        return true;
    }
});
//add by 20141104 allen.qiang FUN-BK-0018-订单修改提示界面改造 end
var productionOrder = {

    dt:"",
    //搜索配件
    search: function() {
        var dt = $('#search_form').serializeArray();
        $("#flex").flexOptions({newp: 1,params: dt}).flexReload();
        //add by 20141105 allen.qiang FUN-BK-0018-订单修改提示界面改造 start
        $("#flex_print").flexOptions({params: dt}).flexReload();
        //add by 20141105 allen.qiang FUN-BK-0018-订单修改提示界面改造 end
    },

    autoSearch: function() {
        var dt = $('#search_form').serializeArray();
        $("#flex").flexOptions({params: dt}).flexReload();
        //add by 20141105 allen.qiang FUN-BK-0018-订单修改提示界面改造 start
        $("#flex_print").flexOptions({params: dt}).flexReload();
        //add by 20141105 allen.qiang FUN-BK-0018-订单修改提示界面改造 end
    },

    deleteConfirm:function(notice_id) {
        this.notice_id = notice_id;
        if( this.notice_id )
            E.confirm("您确认要处理这条数据吗？", "productionOrder.handle");
        else
            E.alert("请选择需要处理的数据");
    },

    handle: function() {
        $.ajax({
            type: "POST",
            url: "/invokingAjax-backend/production/orderModify.ajax?operFlg=2",
            dataType: "JSON",
            data : {
                notice_id: this.notice_id
            },
            success: function( result_obj ) {
                E.loadding.close();
                if (result_obj.code == 200) {
                    E.alert('处理成功',2);
                    productionOrder.load();
                } else {
                    E.alert('处理失败');
                }
            }
        });
    },

//    delete: function() {
//        $.ajax({
//            type: "POST",
//            url: "/invokingAjax-backend/production/orderModify.ajax?operFlg=2",
//            dataType: "JSON",
//            data : {
//                notice_id: this.notice_id
//            },
//            success: function( result_obj ) {
//                E.loadding.close();
//                if (result_obj.code == 200) {
//                    productionOrder.load();
//                } else {
//                    E.alert('删除失败');
//                }
//            }
//        });
//    },

    load: function() {
        $("#flex").flexReload();
    },

    clearUp: function(){
        $('#send_date').val('<!--{$currentDate}-->');
        $('#bill_code').val('');
        $('#bill_status').val('');
        $('#cityID').val('');
        $('#distribution_id').val('');
        productionOrder.load();
    }
};

//每60秒查询一次
    setInterval(productionOrder.autoSearch,60000);


$(window).ready(function() {

    $("#cityID").html("");

    var cityHtml = '<option value="">请选择</option>';

    $.ajax({
        type: "post",
        url: "/invokingAjax-comm/bill/distribution.ajax?operFlg=1",
        dataType: "json",
        data: "",
        success: function( result_obj ) {
            if(result_obj.code == 200){
                $.each(result_obj.data, function(i,val){
                    cityHtml +='<option value="'+val.id+'">'+val.name+'</option>';
                });
                $('#cityID').html(cityHtml);
            }else{
                E.alert(result_obj.message);
            }
        }
    });

    //点击城市联动获得配送站(联动)
    $(document).on('change', '#cityID', function() {

        $('#distribution_id').html("");

        var cityID = $('#cityID').children('option:selected').val();
        var distributionHtml = '<option value="">请选择</option>';
        E.ajax_post({
            url: "/invokingAjax-comm/bill/distribution.ajax?operFlg=2",
            data: {deliver_cityid: cityID},
            call: function( obj ) {
                if(obj.code ==200 && obj.data != null){

                    $.each(obj.data, function(i,val){
                        distributionHtml +='<option value="'+val.distribution_id+'">'+val.distribution_name+'</option>';
                    });
                    $('#distribution_id').html(distributionHtml);
                }else{

                    distributionHtml += '';
                    $('#distribution_id').html(distributionHtml);
                }
            }
        });
    });
});
</script>

</body>

</html>
